package com.example.shilehui;

import cn.jhc.Adapter.CellAdapter;
import cn.jhc.Adapter.SetMyAccountAdapter;
import cn.jhc.service.PublicUserService;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.Window;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class ModifyAccountInfoActivity extends Activity {

	String name;
	EditText info;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.modify_my_account);
		
		Intent intent=getIntent();
		if(intent!=null){
		    name=intent.getStringExtra("name");
		    	 
		}
		
		TextView infoHear=(TextView) findViewById(R.id.modify_my_account_textview);
		info=(EditText) findViewById(R.id.modify_my_account_edittext);
		TextView sure=(TextView) findViewById(R.id.modify_my_account_sure);
		
		
		infoHear.setText(name);		
		if(SetMyAccountAdapter.names[0].equals(name)){
			info.setText(SetMyAccountAdapter.userModifyInfo.getNickname());
		}else if(SetMyAccountAdapter.names[1].equals(name)){
			info.setText(SetMyAccountAdapter.userModifyInfo.getSingleLanage());
		}else if(SetMyAccountAdapter.names[2].equals(name)){
			info.setText(SetMyAccountAdapter.userModifyInfo.getSex());
		}else if(SetMyAccountAdapter.names[3].equals(name)){
			info.setText(SetMyAccountAdapter.userModifyInfo.getProvince());
		}else if(SetMyAccountAdapter.names[4].equals(name)){
			info.setText(SetMyAccountAdapter.userModifyInfo.getArea());
		}else if(SetMyAccountAdapter.names[5].equals(name)){
			info.setText(SetMyAccountAdapter.userModifyInfo.getTel());
		}else if(SetMyAccountAdapter.names[6].equals(name)){
			info.setText(SetMyAccountAdapter.userModifyInfo.getQQ());
		}else if(SetMyAccountAdapter.names[7].equals(name)){
			info.setText(SetMyAccountAdapter.userModifyInfo.getEmail());
		}
		
		sure.setOnClickListener(new sureListener());
		
	}

	private class sureListener implements OnClickListener {

		@Override
		public void onClick(View v) {
			String modifyInfo=info.getText().toString();
			if(SetMyAccountAdapter.names[0].equals(name)){
				SetMyAccountActivity.userModifyInfo.setNickname(modifyInfo);
				PublicUserService.getPublicUserInfo().setNickname(modifyInfo);
			}else if(SetMyAccountAdapter.names[1].equals(name)){
				SetMyAccountActivity.userModifyInfo.setSingleLanage(modifyInfo);
				PublicUserService.getPublicUserInfo().setIdiograph(modifyInfo);
			}else if(SetMyAccountAdapter.names[3].equals(name)){
				SetMyAccountActivity.userModifyInfo.setProvince(modifyInfo);
			}else if(SetMyAccountAdapter.names[4].equals(name)){
				SetMyAccountActivity.userModifyInfo.setArea(modifyInfo);
			}else if(SetMyAccountAdapter.names[5].equals(name)){
				SetMyAccountActivity.userModifyInfo.setTel(modifyInfo);
			}else if(SetMyAccountAdapter.names[6].equals(name)){
				SetMyAccountActivity.userModifyInfo.setQQ(modifyInfo);
			}else if(SetMyAccountAdapter.names[7].equals(name)){
				SetMyAccountActivity.userModifyInfo.setEmail(modifyInfo);
			}
			SetMyAccountActivity.setMyAccountAdapter.notifyDataSetChanged();
			finish();
		}

	}
	
	public void modify_shilehui_back(View v){
		finish();
	}
}
